<?php

/*	Vulpes-backend - Web-based managegent for wireless internet providers.
	Copyright (C) 2007 LinFox Serviços em Informática Ltda.

	This file is part of the Vulpes backend.

	Vulpes-backend is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	Vulpes-backend is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.

 	Please note that any front-end (client application) that is distributed
	along with the Vulpes back-end, such as the Vulpes front-end by LinFox,
	is subject to it's correspending licene. */

class page
{
	var $title;
	var $action;
	var $user;
	var $message = false;
	var $errors;
	var $warnings;
	var $notifications;
	var $content = '';
	
	function __construct()
	{
		global $conf;

		$this->action = get('action');
		$this->title = $conf['sitename'];
	}

	function add_nav()
	{
		return false;
	}
	
	function display()
	{
		global $header;
		global $footer;

		echo $this->parse
		(
			$header .
			$this->content .
			'<message>' .(int)$this->message. '</message>
			<messages>' .$this->errors. $this->warnings. $this->notifications. '</messages>' .
			$footer
		);
	}
	
	function parse($result)
	{
		global $lang;
		global $conf;

		$result = str_replace('{vulpes_site_name}', $conf['sitename'], $result);

		foreach ($lang as $translation) {
			$result = str_replace('{lang_' .key($lang). '}', $translation, $result);
		}
		
		return $result;
	}

	function error($message)
	{
		global $lang;
		$this->message = true;
		$this->errors .= '<message><type>'.$lang['error'].'</type><text>' .$message. '</text></message>';
	}
	function warning($message)
	{
		global $lang;
		$this->message = true;
		$this->warnings .= '<message><type>'.$lang['warning'].'</type><text>' .$message. '</text></message>';
	}
	function notify($message)
	{
		global $lang;
		$this->message = true;
		$this->notifications .= '<message><type>'.$lang['notification'].'</type><text>' .$message. '</text></message>';
	}
}

?>